#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int queue[100][5] = { 0 };
int main()
{
	for (int i = 0; i <= 100; i++)
		queue[i][4] = -1;
	int n;
	scanf("%d", &n);
	for (int i= 1;i<=n; i++) {
		scanf("%d%d%d", &queue[i][1], &queue[i][2], &queue[i][3]);
		for (int a = 10; a <= 100; a++) {
			if (queue[i][1] == a % 3 && queue[i][2] == a % 5 && queue[i][3] == a % 7) {
				queue[i][4] = a; break;
			}
			else queue[i][4] = 0;
		}
	}
	for (int i = 1; i <= 100; i++)
		if (queue[i][4] == 0)
			printf("case %d:No answer\n", i);
		else if(queue[i][4]>0) printf("case %d:%d\n", i, queue[i][4]);
	return 0;
}